<template>
  <div class='box'>
    <!-- 搜索框 -->
    <el-card class="search">
      <el-form ref="form"
               :inline="true"
               class="searchForm"
               :model="form"
               label-width="80px">
        <el-form-item>
          <span>店铺编号/名称</span>
          <el-input v-model="form.name"
                    style="width:60%"></el-input>
        </el-form-item>
        <el-form-item label="行业:">
          <el-col :span="12">
            <el-select v-model="some1"
                       placeholder="请选择">
              <el-option v-for="item in options1"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select>
          </el-col>

          <el-col :span="1">--</el-col>
          <el-col :span="11">
            <el-select v-model="some2"
                       placeholder="请选择">
              <el-option v-for="item in options1"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <el-form-item>
          <el-button @click="onSubmit">查询</el-button>
          <el-button @click="reset">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <!-- 数据表单 -->
    <el-card class="form">
      <el-table :data="list">
        <el-table-column prop="store_id"
                         label="店铺编号">
        </el-table-column>
        <el-table-column prop="store_name"
                         label="店铺名称">
        </el-table-column>
        <el-table-column prop="store_trade"
                         label="店铺行业">
        </el-table-column>
        <el-table-column prop="store_site"
                         label="店铺地址">
        </el-table-column>
        <el-table-column prop="phone"
                         label="联系电话">
        </el-table-column>
        <el-table-column prop="order_count"
                         label="推广人ID">
        </el-table-column>
        <el-table-column prop="equity_level"
                         label="权益级别">
        </el-table-column>
        <el-table-column prop="saleroom"
                         label="销售额↓↑">
        </el-table-column>
        <el-table-column prop="address"
                         label="操作"
                         width="200px">
          <a href="javascript:;">详情</a>
          <a href="javascript:;"
             style="margin:0 20px ">查看商品</a>
          <a href="javascript:;">经营分析</a>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      form: {
        name: ''
      },
      list: [],
      list1: [],
      some1: '',
      some2: '',
      name: '',
      options1: [
        {
          value: '减肥中心',
          label: '减肥中心'
        },
        {
          value: '七七酒店',
          label: '七七酒店'
        },
        {
          value: '私人影院',
          label: '私人影院'
        },
        {
          value: '盲人按摩',
          label: '盲人按摩'
        }
      ],
      newObj: {}
    }
  },

  created () {
    this.getlist()
  },
  mounted () { },
  methods: {
    onSubmit () {
      if (this.form.name) {
        const arr = []
        this.list = this.list1
        this.list.forEach((item, index) => {
          if (item.store_id === this.form.name * 1 || item.store_name === this.form.name) {
            arr.push(item)
          }
          this.list = arr
        })
        if (this.some1 || this.some2) {
          const arr2 = []
          this.list.forEach((item, index) => {
            if (item.store_trade === this.some1 || item.store_trade === this.some2) {
              arr2.push(item)
            }
          })
          this.list = arr2
        }
      } else {
        const arr1 = []
        this.list = this.list1
        if (this.some1 || this.some2) {
          this.list.forEach((item, index) => {
            if (item.store_trade === this.some1 || item.store_trade === this.some2) {
              arr1.push(item)
            }
          })
          this.list = arr1
        }
      }
    },
    async getlist () {
      const { data } = await this.$http.get('/personage')
      this.list = data.list
      this.list1 = data.list
      data.list.forEach((item, index) => {
        item.newsaleroom = item.saleroom + '元'
      })
    },

    tabBtn (val) {
      this.newObj = val
    },
    // a标签跳转
    aBut () {
      setTimeout(() => {
        this.$router.push({
          name: 'PbMan',
          params: {
            id: this.newObj.store_id,
            phone: this.newObj.phone,
            name: this.newObj.store_name,
            num: this.newObj.saleroom
          }
        })
      }, 0.1)
    },
    // 重置按钮
    reset () {
      this.form.name = ''
      this.some1 = ''
      this.some2 = ''
      this.list = this.list1
    }

  }
}
</script>

<style scoped lang="less">
.search {
  margin-bottom: 20px;
  padding: 20px 0 0 0;
  .searchForm {
    display: flex;
    justify-content: left;
    align-content: center;
  }
}
.form {
  padding-left: 15px;
  .el-table {
    font-size: 12px;
  }
}
</style>
